﻿Public Class Frm_ajou_mo9arir
    Dim aray As New List(Of String)
    Dim clos As Boolean = True
    Private Sub Frm_ajou_mo9arir_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Frm_mo9arir.Enabled = True
    End Sub

    Private Sub Frm_ajou_mo9arir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Partager.RemplirList(List_mo9arir, "Comb_mo9arir", "mo9arir")
    End Sub

    Private Sub btn_ajout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajout.Click
        Partager.AjouterWadifa(txt_mo9arir, List_mo9arir, "Comb_mo9arir", "mo9arir")
        Partager.com_ville(Frm_mo9arir.comb_nom_mo9arir, "Comb_mo9arir", "mo9arir")
    End Sub

    Private Sub btn_supp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_supp.Click
        Partager.DeleteFromList(List_mo9arir, "Comb_mo9arir", "mo9arir", txt_mo9arir)
        Partager.com_ville(Frm_mo9arir.comb_nom_mo9arir, "Comb_mo9arir", "mo9arir")
    End Sub

    Private Sub txt_mo9arir_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_mo9arir.TextChanged
        Try
            List_mo9arir.Items.Clear()
            Partager.Remplir(aray, "Comb_mo9arir", "mo9arir")
            For Each item As String In aray
                If item.ToString.Contains(txt_mo9arir.Text) Then
                    List_mo9arir.Items.Add(New ListViewItem(New String() {item.ToString}))
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        If txt_mo9arir.Text = "" Then
            Partager.RemplirList(List_mo9arir, "Comb_mo9arir", "mo9arir")
        End If
    End Sub

    Private Sub List_mo9arir_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles List_mo9arir.DoubleClick
        If List_mo9arir.SelectedIndices.Count > 0 Then
            Frm_mo9arir.comb_nom_mo9arir.Text = List_mo9arir.SelectedItems(0).Text
            Me.Close()
        End If
    End Sub

    Private Sub List_mo9arir_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles List_mo9arir.SelectedIndexChanged

    End Sub
End Class